
	<div class='fixed hwrap'>
		<a href='javascript:history.back(-1);' target='_parent' class='rel'>
			<i class='icon-angle-left'></i>
		</a>
		<a href='javascript:;' target='_parent'></a>
		<h3 class='dyc'>新增收货地址</h3>
	</div>
	<div style='height:45px;'></div>
	<div class="aress_wrap">
  <ul class="wrap">
    <form name="addressForm" method="post" class="layui-form" action="">
    <li>
    	<span class="lab">收货人：</span>
        <input type="text" name="addressname" required lay-verify="required" placeholder="请输入收货人姓名" value="">
    </li>
    <li>
    	<span class="lab">联系电话：</span>
        <input type="text" name="addresstel" required lay-verify="required" placeholder="请输入联系电话" value="">
    </li>
    <li class="cF">
    	<span class="lab">所在地区：</span>

		<select name='province' lay-ignore>
			<option value=''>--省份--</option>
			<?php foreach($provincelist as $key => $value):?>
			  <option value='<?=$value['id']?>'><?=$value['name']?></option>
			<?php endforeach;?>
		</select>
        <select name="city" lay-ignore>
			<option value=''>--选择城市--</option>
		</select>
        <select name="area" lay-ignore>
			<option value=''>--选择城市--</option>
		</select>
    </li>
    <li class="notP">
    	<textarea name="addressmx" required lay-verify="required" placeholder="请输入详细地址，方便快递员投送"></textarea>
	</li>
    <li class="notP">
		<input name="default" lay-ignore type="checkbox" value="1">
        设为默认收货地址
    </li>
	<div style="text-align: center;"><button class="mDivButton" lay-submit  lay-filter="myform">保存</button></div>
    </form>
  </ul>
</div>
<script>
$(function(){
	region("addressForm","province","city","area");

    /******************选择省份，区域，城市*****************/
    function region(FormName,Formprovince,Formcity,Formarea){
        var province = eval('document.' + FormName + "." + Formprovince);
        var city = eval('document.' + FormName + "." + Formcity);
        var area = eval('document.' + FormName + "." + Formarea);
    	//根据省份返回城市
    	province.onchange = function(){
    	    area.innerHTML = "<option value=''>--区域--</option>";
    		$.post("/Publics/getComAddress",{pid:this.value},function(data){
                var areadata = data.data;
                var html = "<option value=''>--城市--</option>";
                for(var i=0;i<areadata.length;i++){
                    html += "<option value='" + areadata[i].id + "'>" + areadata[i].name + "</option>";
                }
    		    city.innerHTML = html;
    		},"json");
    	}
    	//根据省份返回城市
    	city.onchange = function(){
    	    $.post("/Publics/getComAddress",{pid:this.value},function(data){
                var areadata = data.data;
                var html = "<option value=''>--区域--</option>";
                for(var i=0;i<areadata.length;i++){
                    html += "<option value='" + areadata[i].id + "'>" + areadata[i].name + "</option>";
                }
    		    area.innerHTML = html;
    		},"json");
    	}
    }
});
</script>
